package com.example.demo1115.controller;

import com.example.demo1115.dao.BookDao;
import com.example.demo1115.entity.Book;
import com.example.demo1115.entity.bbb;
import com.example.demo1115.service.BookService;
import com.example.demo1115.vo.Result;
import com.fbs.FbsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.apache.ibatis.ognl.DynamicSubscript.all;

@RestController
@RequestMapping("/api")
@Api(tags = "测试")
public class HelloController {

    @GetMapping("/hello")
    @ApiOperation(value = "无参")
    public Map<String,Object> hello(){
        HashMap<String, Object> map = new HashMap<>();
        map.put("name","樊博士");
        map.put("age","18");
        return map;
    }

    @Autowired
    private bbb bbb;
    @GetMapping("/demo")
    public bbb demo(){
        return bbb;
    }
    @Value("${server.port}")
    private Integer port;
    @Value("${aaa.id}")
    private String id;
    @Autowired
    private FbsService fbsService;
    @GetMapping("/info")

    public String info(){
        fbsService.hello();
        return "端口号"+port+"id="+id;
    }
    @Autowired
    private BookService service;
    @PostMapping  ("/select")
    public Result select(Integer current,Integer pageSize){
        Result all1 = service.findAll(current,pageSize);
        return all1;
    }
    @PostMapping("/charu")
    public Result cha(String isbn,String bookName,Integer price){
        Result insertone = service.insertone(isbn, bookName, price);
        return insertone;
    }
    @PostMapping("/update")
    public Result update(String isbn,String bookName,Integer price){
        Result updateone = service.updateone(isbn, bookName, price);
        return updateone;
    }
    @PostMapping("/delete")
    public Result delete(String isbn){
        Result result = service.deleteByisbn(isbn);
        return result;
    }

}
